package com.java.servlet.web.roles.dao.sql;

public class SqlRoles {
	public static final String DATOS_ROLES;
	public static final String DATOS_ROLES_IDROL;
	public static final String SAVE_NUEVO_ROL;
	public static final String MAX_ID_ROL;
	public static final String SAVE_EDIT_ROL;
	public static final String DELETE_ROL;

	static{
		StringBuilder queryBuilder = new StringBuilder();
		queryBuilder.append("SELECT ID_ROL, DESC_ROL, VIGENCIA,(SELECT CASE WHEN VIGENCIA = 'S' THEN 'SI' WHEN VIGENCIA = 'N' THEN 'NO' ELSE '' END ) AS DESC_VIGENCIA FROM SIS_CAT_ROLES ");
		DATOS_ROLES = queryBuilder.toString();
		
		queryBuilder = new StringBuilder();
		queryBuilder.append(" WHERE ID_ROL = ? ");
		DATOS_ROLES_IDROL = queryBuilder.toString();
		
		queryBuilder = new StringBuilder();
		queryBuilder.append("INSERT INTO SIS_CAT_ROLES(ID_ROL,DESC_ROL,VIGENCIA) VALUES(?,?,?)");
		SAVE_NUEVO_ROL = queryBuilder.toString();
		
		queryBuilder = new StringBuilder();
		queryBuilder.append("SELECT COUNT(*) + 1 FROM SIS_CAT_ROLES");
		MAX_ID_ROL = queryBuilder.toString();
		
		queryBuilder = new StringBuilder();
		queryBuilder.append("UPDATE SIS_CAT_ROLES SET DESC_ROL = ?, VIGENCIA = ? WHERE ID_ROL = ?");
		SAVE_EDIT_ROL = queryBuilder.toString();
		
		queryBuilder = new StringBuilder();
		queryBuilder.append("DELETE FROM SIS_CAT_ROLES WHERE ID_ROL = ?");
		DELETE_ROL = queryBuilder.toString();
	}
}
